<template>
	<view class="flex-col zhuyuanriqindan">
		<view class="flex-row wrapper">

			<view class="flex-col flex-row wraper-col">
				<view class="flex-row box">
					<view class="u-line-1 text" style="width: 90px;">{{xz.thePatient.name}}</view>
					<view v-if="xz.status=='住院中'">
						<u-tag text="住院中" shape="circle"></u-tag>
					</view>
					<view v-if="xz.status=='已出院'">
						<u-tag text=已出院 shape="circle"></u-tag>
					</view>
				</view>
				<view class="u-line-1 text-two">{{xz.admissionNumber}}</view>
			</view>


			<!-- <u-tag class="tag" text="父母" shape="circle"></u-tag> -->

			<!-- 切换就诊人开始 -->
			<view style="float: left;margin-left: 80px;width: 65px;height: 65px;" @click="show = true">
				<uni-icons type="staff-filled" size="40" color="#006eff"></uni-icons>
				<br>
				<!-- <u-icon class="" name="coupon" type="staff-filled" :size="40" color="#006eff"></u-icon> -->
				<text style="float: left;margin-left: -15px;color: #bfc2c6;">切换住院人</text>
			</view>
			<!-- 切换就诊人结束 -->
			<!-- <u-icon class="icon-coupon" name="coupon" :size="40" label="切换就诊人" :label-size="24" label-pos="bottom"></u-icon> -->
			<!-- <u-tag class="tag-two" text="tag标签"></u-tag> -->
		</view>
		<view class="flex-col wrapper-two">
			<view class="u-line-1 text-three">花费金额：</view>
			<view class="u-line-1 text-four">￥{{record.money}}</view>
		</view>
		<view style="width: 100%;height: 30px;"></view>
		<!--      <u-button class="button" type="success" size="mini">
            按钮
        </u-button> -->
		<view  class="flex-col wrapper-three">
			<view class="u-line-1 text-five">费用明细</view>
			<u-line class="line" margin="0rpx 0rpx 9.058rpx 0rpx"></u-line>
			<view class="flex-col wraper-row"  v-for="(r, index) in record.d"  :ref="'r'+index" >
				<view class="flex-row box-two">
					<view class="flex-col flex-row box-col">
						<view class="u-line-1 text-six">{{r.drugsName}}</view>
						<view class="flex-col flex-row container">
							<view class="u-line-1 text-seven">单价：</view>
							<view class="u-line-1 text-eight">￥{{r.drugsPrice}}</view>
						</view>
					</view>
					<view class="u-line-1 text-nine">数量：</view>
					<view class="u-line-1 text-ten">{{r.useNumber}}</view>
					<view class="u-line-1 text-eleven">￥{{r.price}}</view>
				</view>
				<u-line class="line-two" margin="0rpx 0rpx 0rpx 0rpx"></u-line>
			</view>
			
			
<!-- 			<view class="flex-col wraper-row-two">
				<view class="u-line-1 text-twelve">普罗布考片</view>
				<view class="u-line-1 text-thirteen">￥60.00</view>
				<view class="u-line-1 text-fourteen">单价：</view>
				<view class="u-line-1 text-fifteen">单价：</view>
				<view class="u-line-1 text-sixteen">￥50.00</view>
				<view class="u-line-1 text-seventeen">5</view>
				<u-line class="line-three" margin="0rpx 0rpx 0rpx 0rpx"></u-line>
			</view> -->
			<view v-if="record.money==0" style="height: 250px;width: 100%;">
				<view style="height: 30px;font-size: 16px;color: #966ed5;margin:108px;">
				<text>没有购买药品记录哦！</text>
				</view>
			</view>
		</view>



		<u-popup :show="show" @close="close" @open="open">
			<view>
				<view style="width: 100%;height: 50px;">
					<text style="float: left;;margin:15px 0px 0px 115px;color:#000;font-size: 26px;">请选择住院人</text>
				</view>


				<view v-for="(item, index) in inpatients" :key="item.id" :ref="'item'+index" @click="onClick(item)"
					style="float: left;margin:0px 0px 0px 5px;border-bottom:2px solid #f2f2f2;margin-top: 5px;">
					<view style="width: 100%;height: 65px;">
						<view style="font-size: 24px;float: left;margin:0px 0px 0px 35px;width: 100px;">
							<text>{{item.thePatient.name}}</text>
						</view>
						<view v-if="item.status=='住院中'"
							style="width: 66px;height: 26px;float: left;;margin:-2px 0px 0px 45px;">
							<u-tag text="住院中" shape="circle"></u-tag>
						</view>

						<view v-if="item.status=='已出院'"
							style="width: 66px;height: 26px;float: left;;margin:-2px 0px 0px 45px;">
							<u-tag text="已出院" shape="circle"></u-tag>
						</view>
						<view style="font-size: 19px;color: #e9dfd7;float: left;;margin:32px 0px 0px -205px;">
							<text>{{item.admissionNumber}}</text>
						</view>
						<view class="tb1">
							<u-icon name="arrow-right" color="#2979ff" size="22"></u-icon>
						</view>
					</view>
				</view>


				


				<!-- <view>
					<u-button class="button1" type="success" shape="circle">
						添加与会人
					</u-button>
				</view> -->
				<view style="clear: both;background-color: #f2f2f2;width: 100%;height: 20px;"></view>

				<view style="height: 60px;" @click="close">
					<u-button class="button1" style="color: #a7a19c;" type="success" shape="circle">
						取消
					</u-button>
				</view>
			</view>
		</u-popup>




	</view>
</template>


<script>
	export default {
		data() {
			return {
				datetimerange: [],
				show: false,
				inpatients: {},
				xz:{
					status:null,
					admissionNumber:null,
					thePatient:{}
				},
				record:{
					money: 0,
					d:{
					}
				}
			}
		},
		onLoad() {
			//获取当前登录用户的id
			const user = uni.getStorageSync("user")
			// console.log(user)
			this.userId = user.id
			// console.log(this.userId)

			//调用方法---（查看当前登录下的所有住院人）
			this.findAllzhuyuanren()
		},
		methods: {
			//查看当前登录下的所有住院人
			findAllzhuyuanren() {
				uni.request({
					url: "http://localhost:9000/user/user/inpatient/inpatientUserId/" + this.userId,
					method: "GET",
					success: (res) => {
						// console.log(res)
						if (res.data.code == 20000) {
							this.inpatients = res.data.data.inpatients
							this.xz = this.inpatients[0]
							console.log(this.inpatients)
							console.log("xz为：：：："+this.xz)
							console.log("id为：：：："+this.xz.id)
							//调用方法 --- (根据当前住院人的id查询该住院人购买的药品记录)
							this.findAllyp()
						}
					}
				})
			},
			findAllyp(){
				console.log("最后的id：：："+this.xz.id)
				uni.request({
					url: "http://localhost:9000/record/record/record/selectByInpatientID/" + this.xz.id,
					method: "GET",
					success: (res) => {
						// console.log(res)
						if (res.data.code == 20000) {
							this.record = res.data.data.record
							if(res.data.data.record == null){
								console.log("zoukong!!!!!")
								this.record = {
									money: 0,
									d:{}
								}
							}
							console.log(this.record)
						}
					}
					
				})
			},
			onClick(item){
				this.xz = item
				this.show = false
				//调用方法 --- (根据当前住院人的id查询该住院人购买的药品记录)
				this.findAllyp()
			},

			open() {
				// console.log('open');
			},
			close() {
				this.show = false
				// console.log('close');
			}
		}
	}
</script>
<style lang="scss" scoped>
	.button1 {
		padding: 25px 0px 25px 0px;
		font-size: 18px;
		background-color: #ffffff;
		color: #3875f2;
		border-color: #f8f8f8;
		border-radius: 0px;
	}

	.tb1 {
		float: left;
		margin: -32px 0px 0px 350px;
	}


	/** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */

	html,
	body {
		margin: 0;
		width: 100%;
		height: 100%;
		font-size: 16px
	}

	view,
	text,
	image {
		position: relative;
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.flex-col {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.flex-row {
		display: flex;
		align-items: flex-start;
	}

	.flex-col .flex-row {
		width: 100%
	}

	/** 全局样式-结束*/

	.zhuyuanriqindan {
		height: 896px;
		padding: 32px 0px 0px 11px;
		border-width: 2px;
		border-top-color: #f5f5f6;
		border-right-color: #f8f8f8;
		border-bottom-color: #f8f8f8;
		border-left-color: #f8f8f8;
		background: #ffffff;
		box-shadow: 2px 2px 2px #F56C6C;

		.wrapper {
			width: 388px;
			height: 102px;
			margin-bottom: 24px;
			padding: 16px 0px 0px 20px;
			border-top-width: 2px;
			border-top-style: solid;
			border-top-color: #f2f6fc;
			border-right-width: 2px;
			border-right-style: solid;
			border-right-color: #f2f6fc;
			border-bottom-width: 2px;
			border-bottom-style: solid;
			border-bottom-color: #f2f6fc;
			border-left-width: 2px;
			border-left-style: solid;
			border-left-color: #f2f6fc;
			background: rgba(245, 249, 255, 1);
			box-shadow: 2px 2px 2px #b9dcff;

			.wraper-col {
				width: 179px;
				margin-right: 16px;

				.box {
					width: 179px;
					justify-content: space-between;
					margin-bottom: 6px;

					.text {
						width: 53px;
						margin-top: 2px;
						font-size: 22px;
					}
				}

				.text-two {
					width: 170px;
					font-size: 14px;
				}
			}

			.tag {
				margin-right: 46px;
			}

			.icon-coupon {
				width: 60px;
				margin-top: 15px;
			}

			.tag-two {
				top: -34920px;
				left: -13479px;
				position: absolute;
			}
		}

		.wrapper-two {
			width: 384px;
			height: 50px;
			margin: 0px 0px 10px 2px;
			padding: 10px 0px 0px 5.5px;
			border-top-width: 2px;
			border-top-style: solid;
			border-top-color: #f8f8f8;
			border-right-width: 2px;
			border-right-style: solid;
			border-right-color: #f8f8f8;
			border-bottom-width: 2px;
			border-bottom-style: solid;
			border-bottom-color: #f8f8f8;
			border-left-width: 2px;
			border-left-style: solid;
			border-left-color: #f8f8f8;
			box-shadow: 5px 5px 5px #d7ebff;

			.text-three {
				width: 127px;
				margin-bottom: -17px;
				font-size: 20px;
			}

			.text-four {
				width: 112px;
				margin-left: 266px;
				font-size: 16px;
				color: rgba(244, 99, 99, 1);
			}
		}

		.button {
			width: 131px;
			margin: 0px 0px 9px 2px;
		}

		.wrapper-three {
			width: 387px;
			// height: 458px;//不设置高，达到动态效果
			margin-left: 2px;
			padding-top: 23px;
			border-top-width: 2px;
			border-top-style: solid;
			border-top-color: #f2f6fc;
			border-right-width: 2px;
			border-right-style: solid;
			border-right-color: #f2f6fc;
			border-bottom-width: 2px;
			border-bottom-style: solid;
			border-bottom-color: #f2f6fc;
			border-left-width: 2px;
			border-left-style: solid;
			border-left-color: #f2f6fc;
			background: rgba(255, 255, 255, 1);
			box-shadow: 2px 2px 2px #b9dcff;

			.text-five {
				width: 92px;
				margin: 0px 0px 9px 16px;
				font-size: 16px;
				color: #aaaaaa;
			}

			.line {
				width: 100%;
				border-width: 2px;
				border-style: solid;
				border-color: #f2f2f2;
			}

			.wraper-row {
				width: 387px;
				margin-bottom: 10px;
				padding: 12px 0px 8px 3.5px;

				.box-two {
					width: 369px;
					margin-left: 11px;

					.box-col {
						width: 121.5px;
						margin-right: 13px;

						.text-six {
							width: 119px;
							margin-bottom: 4px;
							font-size: 14px;
							color: rgba(0, 0, 0, 1);
						}

						.container {
							width: 121.5px;

							.text-seven {
								width: 78px;
								margin-bottom: -20px;
								font-size: 12px;
								color: #aaaaaa;
							}

							.text-eight {
								width: 72px;
								margin-left: 49px;
								font-size: 14px;
								color: #aaaaaa;
							}
						}
					}

					.text-nine {
						width: 40px;
						margin: 24px 1px 0px 0px;
						font-size: 12px;
						color: #aaaaaa;
					}

					.text-ten {
						width: 27px;
						margin: 24px 54px 0px 0px;
						font-size: 14px;
						color: #aaaaaa;
					}

					.text-eleven {
						width: 112px;
						margin-top: 10px;
						font-size: 16px;
						color: rgba(244, 99, 99, 1);
					}
				}

				.line-two {
					width: 383px;
					border-width: 2px;
					border-style: solid;
					border-color: #f2f2f2;
				}
			}

			.wraper-row-two {
				width: 387px;
				padding: 12px 0px 8px 3.5px;

				.text-twelve {
					width: 119px;
					margin: 0px 0px -9px 11px;
					font-size: 14px;
					color: rgba(0, 0, 0, 1);
				}

				.text-thirteen {
					width: 112px;
					margin: 0px 0px -6px 268px;
					font-size: 16px;
					color: rgba(244, 99, 99, 1);
				}

				.text-fourteen {
					width: 78px;
					margin: 0px 0px -20px 11px;
					font-size: 12px;
					color: #aaaaaa;
				}

				.text-fifteen {
					width: 40px;
					margin: 0px 0px -19px 146px;
					font-size: 12px;
					color: #aaaaaa;
				}

				.text-sixteen {
					width: 72px;
					margin: 0px 0px -19px 61px;
					font-size: 14px;
					color: #aaaaaa;
				}

				.text-seventeen {
					width: 27px;
					margin: 0px 0px 2px 187px;
					font-size: 14px;
					color: #aaaaaa;
				}

				.line-three {
					width: 383px;
					border-width: 2px;
					border-style: solid;
					border-color: #f2f2f2;
				}
			}
		}
	}
</style>
